package org.example.leetcode.core.controller;

import org.example.leetcode.codeExecutor.api.CodeExecutorService;
import org.example.leetcode.common.pojo.GlobalResponse;
import org.example.leetcode.core.service.SysFileService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/common")
public class CommonController {
    @Resource
    CodeExecutorService codeExecutorService;
    @Resource
    SysFileService sysFileService;
    @PostMapping("/upload")
    @Transactional
    public GlobalResponse<String> upload(@RequestParam("file") MultipartFile file,@RequestParam("type")String type,@RequestParam("data")String data){
        String res=sysFileService.upload(file,type,data);
        return GlobalResponse.success(res);
    }
}
